//20130824 helper to track process execution status.
#include "tm_processor.h"

using namespace std;


int main(int argc,char ** argv)
{
    try{
        //K 20130825 actually any slotDuration(>1) is OK. set range as [100,10000] 
        //because I think it's resonable value.
        if(argc != 3){
            cout<<"expected two parameters $>  timeline {FileName} {slotDuration_ms} \n"<<
                "eg:  timeLine rawInput.txt 500 \n"<<
                "recommended slotDuration [100/250/500/1000 ... 10000] \n"
                <<"Configed MaxSlot = "<<MAX_SLOTS<<"\n"
                <<"outputFile: currentDir/InputName_parsed.txt \n \n"
                <<"TimeStamp Format(input file) \n"
                <<"[[TrackLineName EventType Time]]  \n"
                <<"EventType shoud be B or E, represent begin or End. Time should be float value >0  \n"
                <<"eg:  ...  [[mainThread B 1.023]] It's OK to mix TimeStamp with other content. "<<endl;
            return -1;
        }

        string fileName(argv[1]);
        int sliceFactor = atoi(argv[2]);
        if (sliceFactor <100 || sliceFactor > 10000)
            throw Error("time slice should be an integer and range from [100,10000]");

        Processor handler(fileName,sliceFactor);
        handler.loadFile();
	handler.parseSlots();
	handler.output();

    }catch(Error & e){
        cout<<"\n !ERROR HAPPENED! \n"<<endl;
        e.what();
        return -1;
    }

    return 0;
}

